<?php
namespace Mobile\Controller;
use Think\Controller;
use Common\Model\Movie;
class MemberController extends BaseController {
    public function index(){
        $membermodel=M('member');
        $list=$membermodel->where("id=".$_SESSION['mobile']['id'])->find();
        $this->assign('data',$list);
        $this->display();
    }

    public function order(){
        $model=M('');
        $id=$_SESSION['mobile']['id'];
       
        date_default_timezone_set('Asia/Shanghai');
        $time1=strtotime(date('Y-m-d H:i:s',time()));

        $sql="select o.id oid,m.id mid,me.id meid,o.status,o.payment_status,u.name username,m.name moviename,m.language,m.actore,m.summary,s.showtime,p.* from `pre_order` o,pre_user u,pre_movie m,pre_screening s,pre_order_item p,pre_member me  where o.user_id=u.id and o.movie_id=m.id and o.screening_id=s.id and o.status<>30 and o.id=p.order_id and me.id=o.member_id and me.id=".$id;

        $list=$model->query($sql);
        date_default_timezone_set('Asia/Shanghai');
        $time1=strtotime(date('Y-m-d H:i:s',time()));
        foreach($list as $key=>$value){

            $list[$key]['show'] = $value['showtime'] <= $time1?'已放映': '未放映';
            $list[$key]['showtime']=date('Y年m月d日 H时i分s秒',$value['showtime']);
            $list[$key]['language']=Movie::languageAlias($value['language']);
            $model1=M('comment')->where(['order_id'=>$value['oid'],'mid'=>$value['meid']])->select();
            $list[$key]['status']=empty($model1)?1:2;
        }
        $this->assign('data',$list);
        $this->display();
    }


}